package com.diyunapp.xilinapp.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.diyunapp.xilinapp.R;
import com.diyunapp.xilinapp.bean.PopList;

import java.util.List;

public class PopListAdapter extends BaseAdapter {

	private Context myContext;
	private List<PopList> myList;
	
	public PopListAdapter(Context myContext, List<PopList> myList) {
		super();
		this.myContext = myContext;
		this.myList = myList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return myList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return myList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView list_info_tv;
		if (convertView == null) {
			convertView = LayoutInflater.from(myContext).inflate(
					R.layout.poplist_item, null);
			list_info_tv = (TextView)convertView.findViewById(R.id.poplist_info_tv);
			 convertView.setTag(list_info_tv);
		}else{
			list_info_tv = (TextView)convertView.getTag();
		}

		PopList list = myList.get(position);
		list_info_tv.setText(list.getPop_info());
		return convertView;
	}

	public class ViewHolder{
		public TextView bank_name_tv;
	}
}
